#include <iostream>

#include "mmseg/mmseg.h"

using namespace std;

int main() {
  if (mmseg_load_chars("./chars.dic") == 0) {
    cerr << "load chars error!" << endl;
  }

  if (mmseg_load_words("./words.dic") == 0) {
    cerr << "load words error!" << endl;
  }

  string text("这是一篇不错的价值投资财经博客文章");
  rmmseg::Algorithm * alg = mmseg_algor_create(text.c_str(), text.size());
  Token token = mmseg_next_token(alg);
  while(token.length > 0) {
    string word(token.text, token.length);
    cout << token.offset << ":" << word << endl;
    token = mmseg_next_token(alg);
  }
  delete alg;

  return 0;
}

